#include <iostream>
#include <vector>
using namespace std;
class TextBlock
{
public:
    TextBlock(std::string str):text(str){}
    const char &operator[](std::size_t position) const { return text[position]; }
    char &operator[](std::size_t position) { return const_cast<char&>( static_cast<const TextBlock&>(*this)[position]); }
    void print(){ std::cout << text  << endl;}
private:
    std::string text;
};

int main()
{
    TextBlock tb("Hello"); 
    std::cout << tb[0] << endl;;
    const TextBlock ctb("World"); 
    std::cout << ctb[0]<< endl;

    tb[0] = 'x' ;
    std::cout << tb[0] << endl;

    tb.print();
    // ctb[0] = 'x';
    std::cout << ctb[0]<< endl;
 
}